home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Languages / MS Cobol4.5 / DEMO / FUNKEY.CBL < prev    next >
Text File  |  1991-04-08  |  2KB  |  55 lines

  1.       $set noosvs mf ans85
  2.       ************************************************************
  3.       *                                                          *
  4.       *              (C) Micro Focus Ltd. 1991                   *
  5.       *                                                          *
  6.       *                      FUNKEY.CBL                          *
  7.       *                                                          *
  8.       *    This program demonstrates how to decode function keys *
  9.       *    using the x"af" call.                                 *
  10.       *                                                          *
  11.       ************************************************************
  12.        special-names.
  13.            crt status is key-status.
  14.  
  15.        working-storage section.
  16.        01 flag                   pic 9(2) comp-x value 1.
  17.        01 user-key-control.
  18.           05 enable-fn-keys      pic 9(2) comp-x value 1.
  19.           05 filler              pic x           value "1".
  20.           05 first-user-key      pic 9(2) comp-x value 1.
  21.           05 number-of-keys      pic 9(2) comp-x value 10.
  22.  
  23.        01 key-status.
  24.           05 key-type            pic x.
  25.           05 key-code-1          pic 9(2) comp-x.
  26.           05 filler              pic x.
  27.        01 any-data               pic x.
  28.        01 key-code-1-display     pic z9.
  29.  
  30.        procedure division.
  31.            perform enable-keys
  32.            perform accept-function-key
  33.            perform tell-which-key-was-pressed
  34.            perform stop-run.
  35.  
  36.        enable-keys.
  37.            call x"af" using flag user-key-control.
  38.  
  39.        accept-function-key.
  40.            display spaces upon crt
  41.            display "Press a function key: F1 to F10" at 0505
  42.            accept any-data at 0540.
  43.  
  44.        tell-which-key-was-pressed.
  45.            evaluate key-type
  46.               when 0 display "You pressed <Enter>" at 0705
  47.               when 1
  48.                    move key-code-1 to key-code-1-display
  49.                    display "You pressed function key" at 0705
  50.                    display key-code-1-display         at 0730
  51.            end-evaluate.
  52.  
  53.        stop-run.
  54.            stop run.
  55.